﻿using Oracle.ManagedDataAccess.Client;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading;
using System.Web.Http;
using Waiyun.WebApi.Data;

namespace Waiyun.WebApi
{
    public class s0501Controller : ApiController
    {
        //public static string ConnectionString;

        static s0501Controller()
        {
            //ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["weitsm_stgccqy2"].ConnectionString;
        }
        private static object s_lockZHLObj = new object();

        [HttpGet]
        public ListResult<double> ZHL()
        {
            string key = "s0501\\zhl";
            object data = Cache2.Get(key);
            if (data == null)
            {
                lock (s_lockZHLObj)
                {
                    data = Cache2.Get(key);
                    if (data == null)
                    {
                        List<double> items = new List<double>();
                        for (int index = 0; index < 30; index++)
                        {

                            items.Add(new Random().Next(288, 500));
                            Thread.Sleep(5);
                        }
                        Cache2.Set(key, items);
                        data = items;
                    }
                }
            }
            return new ListResult<double>((List<double>)data);
        }

        [HttpGet]
        public ListResult<double> ZDDL()
        {
            string key = "s0501\\zddl";
            object data = Cache2.Get(key);
            if (data == null)
            {
                lock (s_lockZHLObj)
                {
                    data = Cache2.Get(key);
                    if (data == null)
                    {
                        List<double> items = new List<double>();
                        for (int index = 0; index < 30; index++)
                        {

                            items.Add(new Random().Next(288, 500));
                            Thread.Sleep(5);
                        }
                        Cache2.Set(key, items);
                        data = items;
                    }
                }
            }
            return new ListResult<double>((List<double>)data);
        }
        [HttpGet]
        public ListResult<double> ZJYE()
        {
            string key = "s0501\\zjye";
            object data = Cache2.Get(key);
            if (data == null)
            {
                lock (s_lockZHLObj)
                {
                    data = Cache2.Get(key);
                    if (data == null)
                    {
                        List<double> items = new List<double>();
                        for (int index = 0; index < 30; index++)
                        {

                            items.Add(new Random().Next(288, 500));
                            Thread.Sleep(5);
                        }
                        Cache2.Set(key, items);
                        data = items;
                    }
                }
            }
            return new ListResult<double>((List<double>)data);
        }
    }
}
